/** \file AudioJack.h
    \author belot.nicolas
    play sound with JACK
*/

#ifndef AUDIOJACK_H
#define AUDIOJACK_H 1

#include "Audio.h"
#ifdef HAVE_LIBJACK
#include <jack/jack.h>


namespace libtrckr {
class AudioJack : public Audio {
/** \class libtrckr::AudioJack
    \brief output via Jack.
*/
	public:
	AudioJack();
	AudioJack(const AudioJack&);

	~AudioJack();
	//int channels() const;
	/**set the number of channels */
	//void channels( int);
	/** get the birate */
	//int bitrate() const;
	/** set the bitrate */
	//void bitrate(int);

	/** Open the output */
	void open();
	/** output state of the Audio */
	audio_state_t state();
	/** Close the output */
	void close();

	/** Append data to the output
	*/
	int append(Buffer b);	

	void param(std::string, std::string);	
	void param(std::string, double);
	void param(std::string, int);

	//int getFrames(int,float*);
	void setSreate(jack_nframes_t);
	jack_port_t *getPort(int);
	static double* obuffer;

	private:
		static int cnt;
		jack_client_t *_handler;
		jack_port_t *_out[2];
		Audio::audio_state_t _state;
		double *rbuffer;
		int min_buffer;
		jack_nframes_t srate;
};

}

#endif

#endif
